{-# OPTIONS -Wall #-}

--------------------------------------------------------------------------------
-- |
-- Module      :  ContML.Types
-- Copyright   :  (c) Stephen Tetley 2012
-- License     :  BSD3
--
-- Maintainer  :  stephen.tetley@gmail.com
-- Stability   :  unstable
-- Portability :  GHC
--
-- Types.
--
--------------------------------------------------------------------------------

module ContML.Types
  (

    Type(..)

  , ppType

  ) where


import Text.PrettyPrint.HughesPJ

data Type = TyUnit
          | TyInt
          | TyExn
          | TyPair Type Type
          | TySum  Type Type
          | TyFun  Type Type
          | TyUnknown
  deriving (Eq,Ord,Show)


-- Types should be printed with precedence so tuples
-- get printed properly
--
-- > ((1,2),3) -> (int * int) * int
--
-- > currently -> ((int * int) * int)


ppType :: Type -> Doc
ppType (TyUnit)         = text "unit"
ppType (TyInt)          = text "int"
ppType (TyExn)          = text "exn"
ppType (TyPair t1 t2)   = ppType t1 <+> char '*' <+> ppType t2
ppType (TySum t1 t2)    = ppType t1 <+> text "[TODO]" <+> ppType t2
ppType (TyFun t1 t2)    = ppType t1 <+> text "->" <+> ppType t2
ppType (TyUnknown)      = text "?Unknown?"

